package thread1;

class MyThread extends Thread{
    @Override
    public void run() {
        while(true){
            System.out.println("进入线程");
            try {
                Thread.sleep(1000);
            } catch (InterruptedException e) {
                throw new RuntimeException(e);
            }
        }
    }
}

public class Demo {
    public static void main(String[] args) throws InterruptedException {
        Thread thread = new MyThread();
        thread.start();
//        thread.run();  //不会创建新的线程
        while(true){
            System.out.println("进入主线程");
            Thread.sleep(1000);
        }
    }
}
